package com.dg.river.core.util;

import android.content.Context;

/**
 * Created by hy on 2018/10/16
 * Description:资源工具类
 */

public class ResourcesUtils {
    private static final String RES_ID = "id";
    private static final String RES_STRING = "string";
    private static final String RES_DRABLE = "drable";
    private static final String RES_LAYOUT = "layout";
    private static final String RES_STYLE = "style";
    private static final String RES_COLOR = "color";
    private static final String RES_DIMEN = "dimen";
    private static final String RES_ANIM = "anim";
    private static final String RES_MENU = "menu";


    /**
     * 获取资源文件的id
     *
     * @param mContext
     * @param resName
     * @return
     */
    public static int getId(Context mContext, String resName) {
        return getResId(mContext, resName, RES_ID);
    }

    /**
     * 获取资源文件string的id
     *
     * @param mContext
     * @param resName
     * @return
     */
    public static int getStringId(Context mContext, String resName) {
        return getResId(mContext, resName, RES_STRING);
    }

    /**
     * 获取资源文件drable的id
     *
     * @param mContext
     * @param resName
     * @return
     */
    public static int getDrableId(Context mContext, String resName) {
        return getResId(mContext, resName, RES_DRABLE);
    }

    /**
     * 获取资源文件layout的id
     *
     * @param mContext
     * @param resName
     * @return
     */
    public static int getLayoutId(Context mContext, String resName) {
        return getResId(mContext, resName, RES_LAYOUT);
    }

    /**
     * 获取资源文件style的id
     *
     * @param mContext
     * @param resName
     * @return
     */
    public static int getStyleId(Context mContext, String resName) {
        return getResId(mContext, resName, RES_STYLE);
    }

    /**
     * 获取资源文件color的id
     *
     * @param mContext
     * @param resName
     * @return
     */
    public static int getColorId(Context mContext, String resName) {
        return getResId(mContext, resName, RES_COLOR);
    }

    /**
     * 获取资源文件dimen的id
     *
     * @param mContext
     * @param resName
     * @return
     */
    public static int getDimenId(Context mContext, String resName) {
        return getResId(mContext, resName, RES_DIMEN);
    }

    /**
     * 获取资源文件ainm的id
     *
     * @param mContext
     * @param resName
     * @return
     */
    public static int getAnimId(Context mContext, String resName) {
        return getResId(mContext, resName, RES_ANIM);
    }

    /**
     * 获取资源文件menu的id
     */
    public static int getMenuId(Context mContext, String resName) {
        return getResId(mContext, resName, RES_MENU);
    }

    /**
     * 获取资源文件ID
     *
     * @param mContext
     * @param resName
     * @param defType
     * @return
     */
    public static int getResId(Context mContext, String resName, String defType) {
        return mContext.getResources().getIdentifier(resName, defType, mContext.getPackageName());
    }
}
